﻿using Abp.Application.Navigation;
using Abp.Authorization;
using Abp.Localization;
using Mt.Site.Core.Base.Navigation;
using Mt.Site.Core.Navigations.Navigation;
using Mt.Site.Core.Taxonomys.Permissions;
using Mt.Site.Core.WorkFlows.Permissions;

namespace Mt.Site.Core.Navigation
{
    public class BackEndSystemPlusProvider : MtNavigationProvider
    {
        public override void SetMtNavigation(MtNavigationProviderContext context)
        {
            var systemMenu = context.Menus[PageNames.SystemMenuName];
            if (systemMenu != null)
            {
                var admin = systemMenu.GetItemByName(PageNames.App.Common.Administration);
                admin.RemoveItem(PageNames.App.Common.StaticPages);

                admin.AddItem(new MenuItemDefinition(
                        PageNamesPlus.App.Tenant.Taxonomy,
                        L("Taxonomy"),
                        url: "taxonomy",
                        icon: "fa-list-ul",
                        permissionDependency: new SimplePermissionDependency(TaxonomyPermissions.Pages_Manage_Taxonomy),
                        customData: null
                        )
                    ).AddItem(new MenuItemDefinition(
                        PageNamesPlus.App.Tenant.WorkFlowTaxonomy,
                        L("WorkFlowTaxonomy"),
                        url: "workFlowTaxonomy",
                        icon: "fa-list-ul",
                        permissionDependency: new SimplePermissionDependency(WorkFlowPermissions.Pages_Manage_WorkFlow_Admin),
                        customData: null
                        ))
                    .AddItem(new MenuItemDefinition(
                        PageNamesPlus.App.Tenant.WorkFlowDesign,
                        L("WorkFlowDesign"),
                        url: "workFlowDesign",
                        icon: "fa-list-ul",
                        permissionDependency: new SimplePermissionDependency(WorkFlowPermissions.Pages_Manage_WorkFlow_Admin),
                        customData: null
                        ));

                var bashboard = systemMenu.GetItemByName(PageNames.App.Tenant.Dashboard);
                systemMenu.Items.Remove(bashboard);
            }
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, MtSiteConsts.LocalizationSourceName);
        }
    }
}
